const { desktopCapturer } = window.require('electron')

exports.getStream = async function() {
    const sources = await desktopCapturer.getSources({ types: ['screen'] })
    return new Promise(function (resolve, reject) {
        navigator.mediaDevices.getUserMedia({
            audio: false,
            video: {
                mandatory: {
                    chromeMediaSource: 'desktop',
                    chromeMediaSourceId: sources[0].id,
                    maxWidth: window.screen.width,
                    maxHeight: window.screen.height
                }
            }
        }).then(function (stream) {
            resolve(stream)
        }).catch(function (err) {
            reject(err)
        })
    })
}
